package com.yihu.dataService.hessian.resource;

import java.io.IOException;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ResourceMongoDBManager {

	private volatile static ResourceMongoDBManager resource;

	private volatile static ApplicationContext applicationContext;

	private ResourceMongoDBManager() throws IOException {
		applicationContext = new ClassPathXmlApplicationContext(
				new String[] { "classpath:/config/spring-config-hessian-servlet.xml" });
	}

	public static ResourceMongoDBManager getSingleton() throws IOException {
		if (resource == null) {
			synchronized (ResourceMongoDBManager.class) {
				if (resource == null) {
					resource = new ResourceMongoDBManager();
				}
			}
		}
		return resource;
	}

	public Object getBeans(String beanName) {
		return applicationContext.getBean(beanName);
	}

//	public Object getBeans(Class name) {
//		return applicationContext.getBean(name.class);
//	}
	
}
